{include file="public/header" /}
<body>
<div class="x-body">
	<form action="{:URL(request()->controller().'/save',['id'=>$info.id,'type'=>$type])}" class="layui-form layui-form-pane" id="form">

		<div class="layui-form-item">
			<label for="express_id" class="layui-form-label">
				<span class="x-red">*</span>快递公司
			</label>
			<div class="layui-input-block">
				<select  name="express_id" id="express_id" lay-filter="express_id" style="max-height: 100px;">
					{volist name="express" id="vo"}
					{if $type != 2}
					<option value="{$vo.ID}" {eq name="$vo.ID" value="$orders.express_id"}selected=""{/eq}>{$vo.Name}</option>
					{else}
					<option value="{$vo.ID}" >{$vo.Name}</option>
					{/if}
					{/volist}
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label for="express_code" class="layui-form-label">
				<span class="x-red">*</span>快递单号
			</label>
			<div class="layui-input-block">
				<input type="text" id="express_code" name="express_code" required="" lay-verify="required" autocomplete="off" class="layui-input" value="{if $type != 2}{$orders.express_code}{/if}">
			</div>
		</div>
		{if $type != 2}
		<input type="hidden" name="id" value="{$orders.id}">
		<div class="layui-form-item">
			<label for="name" class="layui-form-label">
				<span class="x-red">*</span>收货人
			</label>
			<div class="layui-input-block">
				<input type="text" id="name" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input" value="{$orders.name}">
			</div>
		</div>
		<div class="layui-form-item">
			<label for="phone" class="layui-form-label">
				<span class="x-red">*</span>收货电话
			</label>
			<div class="layui-input-block">
				<input type="text" id="phone" name="phone" required="" lay-verify="required|phone" autocomplete="off" class="layui-input" value="{$orders.phone}">
			</div>
		</div>
		<div class="layui-form-item">
			<label for="address" class="layui-form-label">
				<span class="x-red">*</span>收货地址
			</label>
			<div class="layui-input-block">
				<textarea name="address" id="address" placeholder="请输入地址" class="layui-textarea">{$orders.address}</textarea>
			</div>
		</div>
		{/if}
		<div class="layui-form-item" style="text-align: center;">
			<button class="layui-btn" lay-filter="save" lay-submit formObj="#form">保存</button>
		</div>
	</form>
</div>
<script>

	layui.use(['form','layer'], function(){
		$ = layui.jquery;
		var form = layui.form
				,layer = layui.layer;
		//监听提交
		form.on('submit(add)', function(data){
			layer.load();
			//发异步，把数据提交给php
			$.ajax({
				type: 'POST',
				url: '{:URL(\'Orders/editDo\',[\'type\'=>$type,\'id\'=>$id])}',
				data: $("#form").serialize(),
				dataType: "json",
				success: function (data) {
					if (data.status == 1) {
						layer.alert(data.message, function(){
							var index = parent.layer.getFrameIndex(window.name);
							parent.layer.close(index);
							parent.location.reload();
						});
					} else {
						layer.alert(data.message);
					}
				}
			});
			return false;
		});
	});
</script>
</body>

</html>